import './show_shop.html';


import { Template } from 'meteor/templating';
import { Shops } from '/imports/api/shops/shops.js';


Template.show_shop_modal.onCreated(function(){
  let self = this;
  self.shop = new ReactiveVar({
    shopCharge: "..",
    address: "..",
    cover_url: '..',
    shopCharge_id: "..",
    name: "..",
    description: "..",
    createdAt: '',
    foundedAt: "..",
    tel: "..",
    hotLine: "..",
    area: '..',
    mail: '..',
    customqq: '..',
    customwexin: '..',
    hrqq: '..',
    hremail: '..',
    province: '..'
  });

  self.autorun(function(c){
    let shopid = Session.get('one-shop-show');
    if (shopid != undefined) {
      let shop= Shops.findOne({_id: shopid});
      self.shop.set(shop);
    }

  });

})


Template.show_shop_modal.onRendered(function(instance){
  	// $('.ui.modal').modal({
    //   onShow: function(){
    //
    //   }
    // });
});

Template.show_shop_modal.helpers({
  cover_url(){
    return Template.instance().shop.get().cover_url;
  },
  name(){
    return Template.instance().shop.get().name;
  },
  description(){
    return Template.instance().shop.get().description;
  },
  address(){
    return Template.instance().shop.get().address;
  },
  customqq(){
    return Template.instance().shop.get().customqq;
  },
  foundedAt(){
    return Template.instance().shop.get().foundedAt;
  },
  tel(){
    return Template.instance().shop.get().tel;
  },
  createdAt(){
    let date = Template.instance().shop.get().createdAt;
    date = moment(date).format('YYYY年MMMMDD日, HH:mm:ss');
    return date;
  },


});

Template.show_shop_modal.events({
  "click #foo": function(event, template){

  }
});
